

<!--    <title>评论时收货天数</title>-->

<div th:include="amd.html::head-title"></div>
<script>
    var myChart = echarts.init(document.getElementById('main'));
    var all = [];
    $.ajax({
            type: "GET",
            url: "/days/list",
            dataType: "json",
            async: false,
            success: function (data) {
                for (var i = 0; i < data.length; i++) {
                    all[i] = {
                        "value": data[i].num,
                        "name": data[i].day
                    };
                }

            }
        }
    );
    function compare(p){ //这是比较函数
        return function(m,n){
            var a = m[p];
            var b = n[p];
            return a - b; //升序
        }
    }
    all.sort(compare("name"));
    var xray = [];
    for (var i = 0; i < all.length; i++) {
        xray[i] = all[i].name;
    }
    var option = {
        xAxis:{
            name:xray,
            data:xray
        },
        yAxis:{

        },

        series: [
            {
                name: '收货天数',
                type: 'line',
                data: all
            }]
    };
    myChart.setOption(option);
</script>
</body>
</html>